package cn.fl.mfr.web.service.impl;

import java.util.List;

import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.mfr.web.service.IMfrInfoModService;
import cn.fl.mfr.web.transform.MfrInfoModVOTransform;
import cn.fl.mfr.web.vo.MfrInfoModVO;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.mfr.api.IMfrInfoModApiService;
import fl.spl.facade.mfr.condition.MfrInfoModQC;
import fl.spl.facade.mfr.dto.MfrInfoModDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cmm.mid.core.framework.page.Pager;


/**
 * @Description: 厂商信息变更记录 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class MfrInfoModServiceImpl implements IMfrInfoModService {

	/**
	 * 自定义 API 自行注入需要的API服务
	 */
	@Autowired
	private IMfrInfoModApiService mfrInfoModApiService;

	@Override
	public MfrInfoModVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.newWebLogger("主键参数为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_PROD_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			throw new BaseException(BaseExceptionConstant.COMMON_0001, "获取对象主键不能为空!");
		}
		//TODO 业务逻辑
		MfrInfoModDTO dto = this.mfrInfoModApiService.selectMfrInfoModDTOById(id,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(),"","");
		return MfrInfoModVOTransform.toVO(dto);
	}

	@Override
	public Long add(MfrInfoModVO entity) throws BaseException{
		if(null == entity){
			throw new BaseException(BaseExceptionConstant.COMMON_0001,"新增对象不存在!");
		};
		//return this.mfrInfoModApiService.add(MfrInfoModVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return null;
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			throw new BaseException(BaseExceptionConstant.COMMON_0001,"删除对象主键不能为空!");
		};
		//return this.mfrInfoModApiService.removeMfrInfoModDTOById(id);
		//TODO 业务逻辑
		return false;
	}

	/**
     * 删除
     * @param ids
     * @return
     */
	@Override
    public boolean removeByIds(List<Long> ids)throws BaseException{
		if(CollectionUtils.isEmpty(ids)){
			throw new BaseException(BaseExceptionConstant.COMMON_0001,"删除对象主键不能为空!");
		};
		return false;
    }

	@Override
	public boolean modify(MfrInfoModVO entity) throws BaseException{
		if(null == entity){
			throw new BaseException(BaseExceptionConstant.COMMON_0001,"修改对象不能为空!");
		};
		//return this.mfrInfoModApiService.modifyMfrInfoModDTO(MfrInfoModVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return false;
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page){
			page = new Pager();
		}
		//return this.mfrInfoModApiService.searchMfrInfoModListPage(page);
		//TODO 业务逻辑
		return null;
	}

	@Override
	public List<MfrInfoModVO> searchList(MfrInfoModQC condition) throws BaseException {
		if(null == condition){
			BaseLogUtils.newWebLogger("查询参数不能为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_PROD_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			throw new BaseException(BaseExceptionConstant.COMMON_0001,BaseExceptionConstant.COMMON_0001_NAME);
		}
		return MfrInfoModVOTransform.toVOList(this.mfrInfoModApiService.searchList(condition));
	}
}
